﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <string>
using namespace std;

//2.只让visit可以作为BuildingMember的好朋友，visitNon不可以访问私有属性；
class BuildingMember;
class goodGayMember
{
public:
	goodGayMember();
	void visit();
	void visitNon();
private:
	BuildingMember* buildingMember;
};

class BuildingMember
{
	//3.让成员函数visit作为友元函数；
	friend void goodGayMember::visit();
public:
	BuildingMember();
	//1.客厅，卧室；
public:
	string m_SittingRoom;
private:
	string m_BedRoom;
};

goodGayMember::goodGayMember()
{
	buildingMember = new BuildingMember;
}

void goodGayMember::visit()
{
	cout << "好基友正在访问：" << this->buildingMember->m_SittingRoom << endl;
	cout << "好基友正在访问：" << this->buildingMember->m_BedRoom << endl;
}
void goodGayMember::visitNon()
{
	cout << "好基友正在访问：" << this->buildingMember->m_SittingRoom << endl;
	//cout << "好基友正在访问：" << this->buildingMember->m_BedRoom << endl;
}

BuildingMember::BuildingMember()
{
	this->m_SittingRoom = "客厅";
	this->m_BedRoom = "卧室";
}

void testMemberFunc()
{
	goodGayMember gg;
	gg.visit();

	gg.visitNon();//好基友正在访问：客厅
}

//main275：成员函数做为友元函数
int main275()
{
	testMemberFunc();//好基友正在访问：客厅
	//好基友正在访问：卧室

	system("pause");
	return EXIT_SUCCESS;
}